<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>赠品小案例</title>
  <style>
    .tag {
      display: block;
    }
  </style>
</head>

<body>
  <p class="name">
    <!-- 
      <span class="tag">【赠品】xxx</span> 
    -->
  </p>
  <script>
    // ============================== 赠品小案例 ==============================
    const nameP = document.querySelector('.name')
    
    const gift = '50g茶叶,清洗球'

    // 具体步骤：
    // 1.字符串 转 数组 ==> split(',')
    // 2.数组 map + join 可以实现渲染
    
    // 改造为箭头函数的写法
    nameP.innerHTML = gift.split(',').map(ele => ` <span class="tag">【赠品】${ele}</span>`).join('')

  </script>
</body>

</html>